package com.enjoybyte.pangu.global;

import com.enjoybyte.pangu.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BizException.class)
    public Result bizException(BizException e){
        log.error("业务异常:{}",e.getMessage());
        return Result.fail(e.getCode(),e.getMessage());
    }
}
